<template>
  <el-drawer :visible.sync="drawer" direction="rtl" size="50%" :with-header="false" :width="700">
    <div class="drawer_box">
      <div class="drawer_title">
        <div class="drawer_t">
          <div class="drawer_t_l">
            <img class="drawer_t_l_img" src="../../../../../static/skin/herodoo/main/platform/home/img/piliangoumai.png"
              alt="" />
            查看新闻
          </div>
          <img class="drawer_t_r" src="../../../../../static/skin/herodoo/main/platform/home/img/guanbi.png" alt=""
            @click="drawer = false" />
        </div>
      </div>

      <div class="drawer_content">
        <div class="content-box">
          <div class="label">排序:</div>
          <div class="desc">
            {{ news.Sort }}
          </div>
        </div>
        <div class="content-box">
          <div class="label">新闻标题:</div>
          <div class="desc">
            {{ news.Name }}
          </div>
        </div>

        <div class="content-box">
          <div class="label">来源:</div>
          <div class="desc">
            {{ news.SourceID }}
          </div>
        </div>
        <div class="content-box">
          <div class="label">新闻主图:</div>
          <div class="desc">
            <img class="img" :src="getImg" alt="">
          </div>
        </div>
        <div class="content-box">
          <div class="label">新闻详情:</div>
          <div class="desc">
            <div v-html="news.Content"></div>
          </div>
        </div>
        <div class="content-box">
          <div class="label">浏览量(次):</div>
          <div class="desc">
            <!-- 315 -->
          </div>
        </div>
        <div class="content-box">
          <div class="label">操作人:</div>
          <div class="desc">
            {{ news.CreateUserID }}
          </div>
        </div>
        <div class="content-box">
          <div class="label">操作时间:</div>
          <div class="desc">
            {{ news.UpdateTime }}
          </div>
        </div>
      </div>
      <div class="button_list" v-if="news.Status =='已发布'">
        <button style="background-color: #1E1B19;" @click="save(3)">撤销发布</button>
      </div>
    </div>
  </el-drawer>
</template>

<script>
export default {
  name: "cat_dialog",
  props: {
    messageList: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      octopus: this.$parent.octopus,
      drawer: false,
      news: {},
    };
  },
  computed: {
    getImg() {
      let url = '';
      if (this.news.MainImageUrl) {
        url = JSON.parse(this.news.MainImageUrl)[0].url
      }
      return url
    }
  },
  created() { },
  watch: {

  },
  methods: {
    drawerOpen(data) {
      this.drawer = true;
      this.news = data.row;
    },
    save(status) {
      
      this.$confirm(`确定撤销发布这个新闻吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        // type: 'warning'
        center: true
      }).then(res => {
        this.update_api_1275(status);
      }).catch(() => {
        console.log('取消了');
      })
    },
    update_api_1275(status) {

      this.octopus.request.api.post(
        "/Octopus/Engine/Item",
        {
          id: 1275,
          type: 'UPDATE',
          value: this.news.ID,
          cellData: [
            { name: "Status", defaultValue: status },	// 状态
            { name: "UpdateTime", defaultValue: new Date().toJSON().substring(0, 10) + ' ' + new Date().toTimeString().substring(0, 8) },
            // 维护人
            { name: "UpdateUserID", defaultValue: this.octopus.passport.id }
          ],
          paramData: {}
        },
        (data) => {
          if (data.status.code == 200) {
            this.drawer = false;
            this.octopus.tips.success('操作成功。')
            this.$emit('reload')
          } else {
            this.octopus.tips.error(data);
          }
        });
    },
  },
};
</script>
<style scoped>
.drawer_box {
  padding: 3rem 0.8rem 3rem 0;
  height: calc(100% - 5rem);
  display: flex;
  flex-direction: column;
}

.drawer_title {
  box-shadow: 0px 5px 5px rgb(230 228 228 / 30%);
  padding-bottom: 1rem;
  font-size: 1.6rem;
}

.drawer_t {
  padding: 0 2.8rem;
  display: flex;
  justify-content: space-between;
}

.drawer_t_l {
  display: flex;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
}

.drawer_t_l_img {
  width: 2.8rem;
  margin-right: 1rem;
}

.drawer_t_r {
  width: 3rem;
  height: 3rem;
  cursor: pointer;
}

.button_box {
  margin-top: 1rem;
  padding: 0 3rem;
  display: flex;
}

.drawer_content {
  overflow-y: auto;
  margin-top: 1.5rem;
  height: calc(100vh - 11rem);
  padding: 0 3rem;
  width: 100%;
  padding-bottom: 1rem;
}

.drawer_content .title {
  font-size: 1.8rem;
  font-weight: bold;
}

.drawer_content .driver-title {
  margin-top: 1em;
}

.content-box {
  display: flex;
  align-items: center;
  margin: 2rem 0 2rem 2em;
}

.mt-10 {
  margin-top: 10rem;
}

.content-box .label {
  width: 25%;
  font-size: 1.6rem;
}

.content-box .label .label-bold {
  font-size: 1.8rem;
  font-weight: bold;
}

.content-box .desc {
  flex: 1;
  font-size: 1.6rem;
}

.desc .img {
  width: 12rem;
  height: 12rem;
}

.desc>>>img {
  max-width: 100%;
}

.button_list {
  margin-top: 1rem;
  display: flex;
  justify-content: end;
  position: absolute;
  background-color: #ffff;
  bottom: 1rem;
  width: calc(100% - 7rem);
}

.button_list button {
  border: none;
  height: 4rem;
  width: 12rem;
  border-radius: 1rem;
  margin-left: 1rem;
  color: #ffff;
  background-color: #F78C53;
  cursor: pointer;
}
</style>